package com.bumpslide.ui {
	import flash.display.Graphics;
	import flash.geom.Point;		

	/**
	 * @author David Knape
	 */
	public class Draw {
		
		static public function dashedLine( graphics:Graphics, from:Point, to:Point, len:Number=5, gap:Number=5 ) : void {
			var dist:Number = Point.distance(from, to);
			if(dist==0) return;
			var lStep:Number = (len/dist);
			var gStep:Number = (gap/dist);
			var n:Number=0;
			while( n<1 ) {		
				var p1:Point = Point.interpolate( from, to, n );
				n+=lStep;
				var p2:Point = Point.interpolate( from, to, n );
				n+=gStep;
				graphics.moveTo( p1.x, p1.y );
				graphics.lineTo( p2.x, p2.y );				
			}			
		} 
		
		static public function dottedLine( graphics:Graphics, from:Point, to:Point, spacing:Number=5, radius:Number=1 ):void {
			var dist:Number = Point.distance(from, to);
			if(dist==0) return;
			var step:Number = (spacing/dist);
			var n:Number=0;
			while( n<1 ) {		
				var p:Point = Point.interpolate( from, to, n );				
				graphics.drawCircle(p.x, p.y, radius);			
				n+=step;
			}	
		}
	}
}
